package com.dyz.leetcode._01_array;

import java.util.ArrayList;
import java.util.List;

public class _118_generate {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> res = new ArrayList<>();
        //杨辉三角可以看成数组
        for(int row =0; row< numRows;row++) {
            List<Integer> list = new ArrayList<>();
            for (int col = 0; col <= row; col++) {
                if (col == 0 || col == row) {
                    list.add(1);
                } else {
                    List<Integer> preList = res.get(row - 1);
                    list.add(preList.get(col - 1) + preList.get(col));
                }
            }
            res.add(list);
        }
        return res;
    }
}
